(ns lastfm-music-recommendation.view.template
  (:use [hiccup.page :only (html5 include-css include-js)])
  (:require [lastfm-music-recommendation.db.datomic :as datomic]))

(defn layout 
  [body message]
  (html5 
    [:head
     [:meta {:charset "utf=8"}]
     [:meta {:http-equiv "X-UA-Compatible" :content "IE=edge,chrome=1"}]
     [:meta {:name "template" :content "width=device-width, initial-scale=1, maximum-scale=1"}]
     [:title "LastFM music recommendation"]
     (include-css "/css/style.css")
     (include-js "/js/js.js")]
    [:body
     [:div {:class "header"}
      [:h1 {:class "title"} "LastFM Music Recommendation"]]
     [:div {:class "content" :style "padding-top: 0px;"} 
      [:p {:class "message"} message]
      [:div {:class "rating"} body]]
     [:a {:href "#" :onclick "crawl()"} "Start crawling"] "  " 
     [:a {:href "#" :onclick "crawlstop()"} "Stop crawling"]]))

(defn home-layout 
  ([session content rated-no]
    (home-layout session content rated-no ""))
  ([session content rated-no query]
      (layout (html5
                [:table {:width "100%" :style "padding-left: 10px;"}
                 [:tr 
                  [:td {:style "vertical-align:top;"} (str "Logged in as: " (:user session) ". Songs rated: " rated-no ". Songs in db: " 
                                                           (datomic/get-songs-number) ". Visited: " (datomic/get-visited-links-number) 
                                                           ". Links: " (datomic/get-links-number))]
                  [:td {:align "right" }
                   [:form {:method "get" :action "/search"}
                    [:p {:style "margin: 0px;"} "Search: " 
                     [:input {:type "text" :name "query" :value query}] 
                     [:input {:type "hidden" :name "page" :value "1"}] 
                     [:input {:type "submit" :value "Search"}]]]]]
                 [:tr 
                  [:td 
                   [:a {:href "/home"} "Home"] " "
                   [:a {:href "/save"} "Save"]" "
                   [:a {:href "/saved"} "Saved songs"]" "
                   [:a {:href "/logout"}"Log out"]]]]
                [:div {:class "rating"} content]) "")))
